import { AuthTableItem, AuthTableParam } from './model/authListModel';
import { workOrderHttp } from '/@/utils/http/axios';

enum Api {
  GET_AUTH_TABLE = '/v1/groupManager/groupAuthorityPage',
}

export const getAuthTable = async (params: AuthTableParam) => {
  const res = await workOrderHttp.post<AuthTableItem>({
    url: Api.GET_AUTH_TABLE,
    params,
  });
  res.records.map((item) => {
    if (item.isOMAdmin == true) {
      item.appName = item.resourceList;
      item.compoName = '--';
      return item;
    } else {
      item.appName = '--';
      item.compoName = item.resourceList;
      return item;
    }
  });
  return res;
};
